<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>管理员登录</title>
    <link href="__PUBLIC__/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/alert/sweetalert.css" rel="stylesheet">
    <script src="__PUBLIC__/jquery/jquery1.8.0.js"></script>
    <script src="__PUBLIC__/alert/sweetalert.min.js"></script>
</head>
<style>
    input{
        font-size: 13px;
        border-radius: 3px;
    }
    input[name="name"] {
        margin-top: 40%;
    }
    button[name="tologin"]{
        font-size: 14px;
        border-radius: 3px;
        width: 20%;
        line-height: 200%;
        margin: 5rem auto;
        display: block;
    }
    body{
    position: relative;
    top: -20px;
}
</style>
<body>

<div class="container">

    <form action="{:U('Login/to_login')}" class="tologin" method="post">
        <div class="form-group"> <!--<label for="exampleInputEmail1">请输入密码：</label>-->
            <input type="text" name="name" class="form-control input-lg" placeholder="请输入用户名" required>
        </div>
        <div class="form-group"> <!--<label for="exampleInputEmail1">请输入密码：</label>-->
            <input type="password" name="passwd" class="form-control input-lg" placeholder="请输入密码" required>
        </div>
        <button type="submit" name="tologin" class="btn btn-default btn-lg">登录</button>
    </form>
</div>


</body>
<script>
    $('.tologin').submit(function(){
        var post_data = $(this).serialize();
        var post_url = $(this).attr('action');
        $.ajax({
            url: post_url,
            type: 'post',
            data: post_data,
            dataType:'json',
            success:function(res){
                console.log(res)
                switch (res.Code){
                    case 100:
//                            console.log(res.Data.go_url);return;
                        window.location.href = res.Data.go_url;
                        break;
                    case 101:
                        swal('登录失败', res.Message, "error");
                        break;
                }
            },
            error:function(){

            }
        });
        return false;
    });

</script>
</html>
